package com.neusoft.nepm.utils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zouran
 * createDate：2023/6/18  23:58
 */
@Configuration
@EnableSwagger2
public class Swagger2 {
    /*  swagger会帮助我们生成接口文档
     * 1：配置生成的文档信息:比如文档名称、作者、版本..
     * 2: 配置生成规则
     * 文档访问： http://ip:port/doc.html
     * */
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.neusoft.nepm.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("东软环保公众监督系统API⽂档")
                .description("文档说明：《东软环保公众监督系统-网格员》后端接口文档")
                .version("1.0")
                //可以省略
                //.contact(new Contact("小花", "www.xiaohua.com", "xiaohua@qq.com"))
                .build();
    }
}
